<template>
  <div>
      <myheader/>
      
      展示我的文件列表
      <table>
          <tr>
              <td></td>
              <td></td>
              <td></td>
          </tr>
          <tr v-for="i in filelist">
              <td>{{i.name}}</td>
              <td>
                  <van-image
                width="10rem"
                height="10rem"
                :src="i.url"
                />
              </td>
              <td>
                  <van-button @click="del(i.name)">删除</van-button>
              </td>
          </tr>
      </table>
      
  </div>
</template>

<script>
import myheader from '@/components/myheader'
export default {
    data(){
        return{
            filelist:[],
            userid:localStorage.getItem('userid')
        }
    },
    methods:{
        getFilelist(){
            this.axios.get('users/getFiles?userid='+this.userid).then(res=>{
                this.filelist=res.data.list
            })
        },
        del(name){
            this.axios.delete('users/getFiles?userid='+this.userid+'&filename='+name).then(res=>{
                this.getFilelist()
        }
    },
    mounted(){
        this.getFilelist()
    },
    components:{
        'myheader':myheader
    }
}
</script>

<style>

</style>